﻿using System;
using System.Windows;
using ColinHan.BlamBlam.Client.ViewModels;
using ColinHan.BlamBlam.Client.Views;

namespace ColinHan.BlamBlam.Client
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow mainWindow = new MainWindow();
            var viewModel = new MainWindowViewModel();
            mainWindow.DataContext = viewModel;

            // When the ViewModel asks to be closed, 
            // close the window.
            EventHandler handler = null;
            handler = delegate
            {
                viewModel.RequestClose -= handler;
                mainWindow.Close();
            };
            viewModel.RequestClose += handler;

            mainWindow.Show();
        }
    }
}
